﻿/* MVC 3 Way of defining validators */
jQuery.validator.unobtrusive.adapters.add("priceonrange", ['minprice', 'maxprice'], function (rule) {
	rule.rules['priceonrange'] = rule.params;
	rule.messages['priceonrange'] = rule.message;
});

jQuery.validator.addMethod('priceonrange', function (value, element, param) {
	if (parseFloat(value) > parseFloat(param.maxprice) || parseFloat(value) < parseFloat(param.minprice)) {
		return false;
	}
	return true;
});




jQuery.validator.unobtrusive.adapters.add("isalphanum", function (rule) {
	rule.rules['isalphanum'] = rule.params;
	rule.messages['isalphanum'] = rule.message;
});

jQuery.validator.addMethod('isalphanum', function (value, element, param) {
	var res = value.match(/^[a-z0-9 \.]+$/i);
	return (res != null);
});





